import React, { Component } from "react"
import ItemCss from "./index.module.css"
import PropTypes from "prop-types"

export default class Item extends Component {
  static propTypes = {
    changes: PropTypes.func.isRequired,
    clicks: PropTypes.func,
    deletes: PropTypes.func.isRequired,
    item: PropTypes.object.isRequired,
  }
  render() {
    let { item, clicks, changes, deletes } = this.props
    return (
      <div className={ItemCss.item}>
        <input type="checkbox" defaultChecked={item.check} onChange={changes} />
        <span onClick={clicks} style={{ margin: "20px" }}>
          {item.check}
          {item.name}
        </span>
        <span className={ItemCss.delete} onClick={deletes}>
          删除
        </span>
      </div>
    )
  }
}
